// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  // return request<{
  //   data: API.CurrentUser;
  // }>('/api/currentUser', {
  //   method: 'GET',
  //   ...(options || {}),
  // });
  return request(`${API_URL}/v1/currentUser`, {
    method: 'GET',
    params: options,
  });
}

/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  // return request<Record<string, any>>('/api/login/outLogin', {
  return request<Record<string, any>>(`${API_URL}/v1/outLogin`, {
    method: 'POST',
    ...(options || {}),
  });
}

export async function getUsers(options?: { [key: string]: any }) {
  return request(`${API_URL}/v1/users`, {
    method: 'GET',
    ...(options || {}),
  });
}
export async function getRoles(options?: { [key: string]: any }) {
  return request(`${API_URL}/v1/roles`, {
    method: 'GET',
    ...(options || {}),
  });
}

// 修改角色
export async function putRole(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/roles`, {
    method: 'PUT',
    ...(options || {}),
  });
}
// 获取所有的权限列表
export async function getPermissions(options?: { [key: string]: any }) {
  return request(`${API_URL}/v1/permission`, {
    method: 'GET',
    ...(options || {}),
  });
}
// 获取所有的音乐列表
export async function getMusic() {
  return request(`${API_URL}/v1/music`, {
    method: 'GET',
    ...{},
  });
}

// 新增角色
export async function addRole(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/roles`, {
    method: 'POST',
    ...(options || {}),
  });
}
// 新增用户
export async function AddUser(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/user`, {
    method: 'POST',
    ...(options || {}),
  });
}
// 删除用户
export async function DeleteUser(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/user`, {
    method: 'DELETE',
    ...(options || {}),
  });
}
// 删除角色
export async function DeleteRole(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/roles`, {
    method: 'DELETE',
    ...(options || {}),
  });
}

// 修改用户
export async function putUser(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/user`, {
    method: 'PUT',
    ...(options || {}),
  });
}
export async function putPermission(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/permission`, {
    method: 'PUT',
    ...(options || {}),
  });
}

export async function deleteRolePermission(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/rolePermission`, {
    method: 'DELETE',
    ...(options || {}),
  });
}


// 新增权限
export async function addPermission(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/permission`, {
    method: 'POST',
    ...(options || {}),
  });
}

// 删除用户
export async function DeletePermission(options: any) {
  return request<API.LoginResult>(`${API_URL}/v1/permission`, {
    method: 'DELETE',
    ...(options || {}),
  });
}

/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  // return request<API.LoginResult>('/api/login/account', {
  return request<API.LoginResult>(`${API_URL}/login`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>('/api/notices', {
    method: 'GET',
    ...(options || {}),
  });
}

// 获取聊天记录
export async function getChatLog(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>(`${API_URL}/v1/chatLog`, {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RuleList>('/api/rule', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    method: 'DELETE',
    ...(options || {}),
  });
}
